package com.fzy.auth.service;

import java.util.LinkedList;
import java.util.List;

import com.fzy.auth.entity.Contact;
import com.fzy.auth.mapper.ContactListMapper;
import com.fzy.auth.query.ContactQuery;
import com.fzy.core.BaseService;

public class ContactService extends BaseService {

	ContactListMapper contactListMapper;

	public List list(ContactQuery query) {
		String sql = "select * from fz_contact where 1=1";
		List params = new LinkedList();
		sql += getConditionSql(query.getUserId(), "user_id =", params);
		sql += getConditionSql(query.getEmail(), "email like", params, true);
		return query(sql, params.toArray(), contactListMapper);
	}

	public Contact get(Long id) {
		return (Contact) getSession().get(Contact.class, id);
	}

	public void setContactListMapper(ContactListMapper contactListMapper) {
		this.contactListMapper = contactListMapper;
	}

}
